<template>
  <section>
    <el-table :data="jobList">
      <el-table-column type="index" label="序号"/>
      <el-table-column label="姓名" prop="mark"/>
      <el-table-column label="操作" width="180" fixed="right">
        <template slot-scope="scope">
          <span v-if="scope.row.state == 3">已导入</span>
          <el-button v-else size="mini" type="success" @click="confirmLearnerBtn(scope.row)">确定</el-button>
        </template>
      </el-table-column>
    </el-table>
  </section>
</template>

<script>
  import dateFormater from '@/common/date-formater'
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import errHandler from '@/assets/errHandler.js'
  import Vue from 'vue'//后续添加属性，需要vue联动
  export default {
    name: "loadLearnerByJob",
    props:['course'],
    data() {
      return {
        jobList:null
      }
    },
    created(){
      this.getJobList()
    },
    computed: {
      ...mapGetters(['department']),
    },
    watch:{},
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      getJobList(sizeNo){
        this.fetch({name:"getJobList",data:{jobTypeId:5,departmentId:this.department.id,size:sizeNo?sizeNo:null}})
          .then(res=>{
            if(res.content.length >= res.totalElements){
              this.jobList=res.content.filter(c=>c.data.sn === this.course.sn)
            }else {
              this.getJobList(res.totalElements)
            }
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
      confirmLearnerBtn(row){
        this.$emit('confirmLoad',row)
      },
    }
  }
</script>

<style scoped>

</style>
